<?php 
require "DataLoad.php"; 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html>
<head>
<title><?php echo $GuildName;?> - DKP系统</title>
<script language="JavaScript" src="inc/jquery.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="Generator" content="EditPlus">
<meta name="Author" content="SULei">
<meta name="Keywords" content="FSDKP DKP WOW GUILD RAID">
<meta name="Description" content="">
<link href="<?php echo $StylePath;?>/main.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="<?php echo $StylePath;?>/styleplus.js"></script>
<style type="text/css" media="all">

</style>
</head>

<body>
<div class="header">
<?php require "menu.php"; ?>
</div>
<div class="main">
	<?php 
ExportXML();
?>
	复制以下内容保存为.XML文件
	<textarea name="" rows=35" cols="160"><?php echo $XMLdata;?></textarea>
</div>
<?php require "footer.php"; ?>
</body>
</html>
<?php 
function ExportXML() {
	extract($GLOBALS);

//Baseinfo
	if (!is_numeric(${"id"})) {
		return $function_ret;

	} 

	$Rid=${"id"};
	$sql="select top 1 * from raid where id=".$Rid;
	$result = mysql_query($sql);$sql  $conn
	$StartTime=$result["Raid_actionTime"];
	$EndTime=$result["raid_endtime"];
	$RaidTitle=$result["Raid_Name"];
	$arrPlayer=explode(", ",$result["Raid_player"]);

//ExtraXML
	$ExtraXML=$ExtraXML."<Extra><Endtime>".$EndTime."</Endtime><DKPrule>".$result["raid_ruler"]."</DKPrule><DKPclass>".$result["raid_class"]."</DKPclass><DKPverify></DKPverify></Extra>";

	$result->close;

//JoinInfo
	for ($i=0; $i<=count($arrPlayer); $i=$i+1) {
		$sql="select top 1 id,player_name,player_race,player_class from player where id=".$arrPlayer[$i];
		$result = mysql_query($sql);$sql    $conn
		$JoinXML=$JoinXML."<key".$i+1."><player>".$result["player_name"]."</player><race>".$result["player_race"]."</race><class>".$result["player_class"]."</class><level>60</level><time>".CheckJoin($result["id"],$Rid,$StartTime)."</time></key".$i+1.">"."\r\n";
		$result->close;

	}

	$JoinXML="<Join>"."\r\n".$JoinXML."</Join>"."\r\n";

//LeaveInfo
	$sql="select * from raid_event where event_class='离开' and event_raidid=".$Rid;
	$result = mysql_query($sql);$sql  $conn
	if (!($result->bof || $result->eof)) {

		for ($i=1; $i<=$result->recordcount; $i=$i+1) {
			$LeaveXML=$LeaveXML."<key".$i."><player>".id2name2($result["event_object"])."</player><time>".$result["event_time"]."</time></key".$i.">"."\r\n";
			$result->movenext;

		}

	} 

	$result->close;
	$LeaveXML="<Leave>"."\r\n".$LeaveXML."</Leave>"."\r\n";

//LootInfo & EventInfo
	$sql="select * from raid_event where event_raidid=".$Rid." order by event_time";
	$result = mysql_query($sql);$sql  $conn
	$ia=1;
	$ib=1;
	for ($i=1; $i<=$result->recordcount; $i=$i+1) {
		switch ($result["event_class"]) {
			case "拾取":
				$LootXML=$LootXML."<key".$ia."><ItemName>".$result["event_object2"]."</ItemName><ItemID>00000:0:0:0</ItemID><Color>ffa335ee</Color><Count>1</Count><Player>".id2name2($result["event_object"])."</Player><Time>".$result["event_time"]."</Time><Note>".$result["event_dkp"]."</Note></key".$ia.">"."\r\n";
				$ia=$ia+1;
				break;
			case "分解":
				$LootXML=$LootXML."<key".$ia."><ItemName>".$result["event_object2"]."</ItemName><ItemID>00000:0:0:0</ItemID><Color>ffa335ee</Color><Count>1</Count><Player>".id2name2($result["event_object"])."</Player><Time>".$result["event_time"]."</Time><Note>ENC</Note></key".$ia.">"."\r\n";
				$ia=$ia+1;
				break;
			case "仓库":
				$LootXML=$LootXML."<key".$ia."><ItemName>".$result["event_object2"]."</ItemName><ItemID>00000:0:0:0</ItemID><Color>ffa335ee</Color><Count>1</Count><Player>".id2name2($result["event_object"])."</Player><Time>".$result["event_time"]."</Time><Note>BOE</Note></key".$ia.">"."\r\n";
				$ia=$ia+1;
				break;
			case "首次":
				$EventXML=$EventXML."<key".$ib."><EventClass>首次</EventClass><Player>".id2name2($result["event_object"])."</Player><Event>".$result["event_object2"]."</Event><Time>".$result["event_time"]."</Time></key".$ib.">"."\r\n";
				$ib=$ib+1;
				break;
			case "发现":
				$EventXML=$EventXML."<key".$ib."><EventClass>发现</EventClass><Player>".id2name2($result["event_object"])."</Player><Event>".$result["event_object2"]."</Event><Time>".$result["event_time"]."</Time></key".$ib.">"."\r\n";
				$ib=$ib+1;
				break;
			case "收割":
				$EventXML=$EventXML."<key".$ib."><EventClass>收割</EventClass><Player>".id2name2($result["event_object"])."</Player><Event>".$result["event_object2"]."</Event><Time>".$result["event_time"]."</Time></key".$ib.">"."\r\n";
				$ib=$ib+1;
				break;
		} 
		$result->movenext;

	}

	$result->close;
	$LootXML="<Loot>"."\r\n".$LootXML."</Loot>"."\r\n";
	if ($EventXML!="") {
		$EventXML="<Event>"."\r\n".$EventXML."</Event>"."\r\n";
	} 






//Export
	$sql="select";
	$XMLdata=$XMLdata."<?xml version=\"1.0\" encoding=\"gb2312\"?>"."\r\n";
	$XMLdata=$XMLdata."<RaidInfo>"."\r\n"."<key>".$StartTime."</key><note>".$RaidTitle."</note>"."\r\n".$JoinXML.$LeaveXML.$LootXML.$EventXML.$ExtraXML."\r\n"."</RaidInfo>";
	return $function_ret;
} 


function CheckJoin($id,$rid,$Default) {
	extract($GLOBALS);

	$sql="select top 1 * from raid_event where event_object='".$id."' and event_class='加入' and event_raidid=".$rid;
	mysql_query($result2);
	if ($result2->eof || $result2->bof) {

		$function_ret=$Default;
	}
		else
	{

		$function_ret=$result2["event_time"];
	} 

	$result2->close;
	return $function_ret;
} 
?>


	
	
		

